package com.jbp.controller;

import com.jbp.exception.RRException;
import com.jbp.model.Gift;
import com.jbp.model.SendGiftRecord;
import com.jbp.service.SendGiftRecordService;
import com.jbp.utils.PageUtils;
import com.jbp.utils.R;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

import java.util.List;
import java.util.Map;

/**
 * 送礼记录(SendGiftRecord)表控制层
 * @author cc
 * @since 2020-06-26 16:23:34
 */
@Api(tags ="APP接口--礼物记录" )
@ApiIgnore
@RestController
@RequestMapping("rest/sendGiftRecord")
public class SendGiftRecordController {
    @Autowired
    private SendGiftRecordService sendGiftRecordService;

    /** 礼物墙 */
    @ApiOperation(value="礼物墙")
    @ApiResponses({
            @ApiResponse(code = 200,message = "成功",response = SendGiftRecord.class),
            @ApiResponse(code = 201,message = "返回失败信息")
    })
    @GetMapping("/giftWall")
    public R giftWall(@RequestParam(value = "otherId", required = true)Integer otherId){
        if (otherId==null) {
            throw new RRException("参数错误");
        }
        List<Gift> gifts = sendGiftRecordService.getGiftWall(otherId);
        return R.ok(gifts);
    }

    /** 收礼记录 */
    @ApiOperation(value="收礼记录")
    @ApiResponses({
            @ApiResponse(code = 200,message = "成功",response = SendGiftRecord.class),
            @ApiResponse(code = 201,message = "返回失败信息")
    })
    @GetMapping("/reciverList")
    public R reciverList(@RequestParam Map<String, Object> params,@RequestAttribute("userId") Integer userId){
        params.put("userId",userId);
        PageUtils page = sendGiftRecordService.queryPage(params);
        return R.ok(page);
    }

    /** 贡献榜 房间 全局 贡献值排名列表 */
    @ApiOperation(value="房间 全局 贡献值排名列表")
    @ApiResponses({
            @ApiResponse(code = 200,message = "成功",response = SendGiftRecord.class),
            @ApiResponse(code = 201,message = "返回失败信息")
    })
    @ApiImplicitParams({
            @ApiImplicitParam(name = "token",value = "token",paramType = "query"),
            @ApiImplicitParam(name="sessionId",value = "sessionId",paramType = "query"),
            @ApiImplicitParam(name="roomId 为null 全服查询  不为空房间查询",value = "roomId",paramType = "query"),
            @ApiImplicitParam(name="type 根据本天 day 本周 week 本月 month 昨天 yesterday 上月 lastMonth 上周 lastWeek",value = "sessionId",paramType = "query"),
    })
    @GetMapping("/devoteList")
    public R devoteList(@RequestParam Map<String, Object> params,@RequestAttribute("userId") Integer userId){
        params.put("userId",userId);
        if (params.get("type") == null && params.get("type") == ""){
            return R.error("参数错误");
        }
        List<SendGiftRecord> giftRecords = sendGiftRecordService.sendList(params);
        return R.ok(giftRecords);
    }

    /** 房间 魅力榜 全局 魅力值排名列表 */
    @ApiOperation(value="房间 全局 魅力值排名列表")
    @ApiResponses({
            @ApiResponse(code = 200,message = "成功",response = SendGiftRecord.class),
            @ApiResponse(code = 201,message = "返回失败信息")
    })
    @ApiImplicitParams({
            @ApiImplicitParam(name = "token",value = "token",paramType = "query"),
            @ApiImplicitParam(name="sessionId",value = "sessionId",paramType = "query"),
            @ApiImplicitParam(name="roomId 为null 全服查询  不为空房间查询",value = "roomId",paramType = "query"),
            @ApiImplicitParam(name="type 根据本天 day 本周 week 本月 month 昨天 yesterday 上月 lastMonth 上周 lastWeek",value = "sessionId",paramType = "query"),
    })
    @GetMapping("/heartList")
    public R heartList(@RequestParam Map<String, Object> params,@RequestAttribute("userId") Integer userId){
        params.put("userId",userId);
        if (params.get("type") == null && params.get("type") == ""){
            return R.error("参数错误");
        }
        List<SendGiftRecord> giftRecords = sendGiftRecordService.heartList(params);
        return R.ok(giftRecords);
    }



}